package ooday03;

public class Test {
    public static void main(String[] args) {
        //测试类
        Dog dog = new Dog("小黑",2,"黑");
        System.out.println(dog.name);
        dog = null; //表示空,没有只想任何对象
        System.out.println(dog.name);

        /**
         * 引用类型数组 与 基本类型数组的区别
         *      1.给引用类型数组的元素赋值时,需要new一个对象
         *      2.访问引用类型数组的元素的属性/行为时,需要打点访问
         */
        //狗类
        Dog[] dogs =new Dog[3];
        dogs[0] = new Dog("小黑",2,"黑");
        dogs[1] = new Dog("小白",1,"白");
        dogs[2] = new Dog("小灰",3,"灰");
        for (int i = 0; i < dogs.length; i++) { //遍历dogs数组
            System.out.println(dogs[i].name);//输出每只狗狗的名字
            dogs[i].eat();//每只狗狗吃饭
        }

        //鸡类
        Chick[] chicks = new Chick[2];
        chicks[0] = new Chick("蔡徐坤",2,"黑白");
        chicks[1] = new Chick("爱坤",1,"黄");
        for (int i = 0; i < chicks.length; i++) {  //遍历chicks数组
            System.out.println(chicks[i].name);//输出每只鸡的名字
            chicks[i].deposit(); //每只鸡都在下蛋
        }

        //鱼类
        Fish[] fish = new Fish[4];
        fish[0] = new Fish("胖头",1,"银");
        fish[1] = new Fish("鲶鱼",2,"黑");
        fish[2] = new Fish("小鲤",3,"红");
        fish[3] = new Fish("花花",4,"黄色");
        for (int i = 0; i < fish.length; i++) {
            System.out.println(fish[i].name);
            fish[i].swim();
        }










        /*
        //狗类
        Dog dog = new Dog("旺财",2,"绿");
        dog.drink();
        dog.eat();
        dog.lookHome();

        //鸡类
        Chick chick = new Chick("爱坤",26,"黄");
        chick.drink();
        chick.eat();
        chick.deposit();

        //鱼类
        Fish fish = new Fish("王多鱼",24,"银");
        fish.drink();
        fish.eat();

         */











    }
}
